//
//  CheckStatusViewController.swift
//  DSHCMerchant
//
//  Created by 罗德良 on 2018/5/6.
//  Copyright © 2018年 袋鼠好车. All rights reserved.
//

import UIKit
import Alamofire
class CheckStatusViewController: BaseViewController {

    @IBOutlet var statusImageView: UIImageView!
    
    @IBOutlet var contentLabel: UILabel!
    
    
    @IBOutlet var sureBtn: UIButton!
    
    var checkStatus = ""  //0 拒绝   1 审核中
    
    override func viewDidLoad() {
        super.viewDidLoad()
        if checkStatus == "0" {//拒绝
            requestGetBackInfo()
        
        }else if checkStatus == "1" {//审核中
            statusImageView.image = UIImage.init(named: "审核中")
            contentLabel.text = "店铺正在审核中，请耐心等待"
        }
        

    }

    @IBAction func sureBtn(_ sender: UIButton) {
        
        if checkStatus == "0" {//拒绝
            let shopCheckVC = ShopCheckViewController();
            shopCheckVC.title = "店铺认证"
            self.navigationController?.pushViewController(shopCheckVC, animated: true)
        }else if checkStatus == "1" {//审核中
            self.navigationController?.popToRootViewController(animated: true)
        }
        
    }
    
    //获取返回状态信息
    func requestGetBackInfo() -> Void {
        Alamofire.request(getShopCheckInfoUrl, method:.post, parameters:["uid":UserModel.shareUser.data?.uid ?? String()])
            .responseString { response in
                
                switch response.result.isSuccess {
                case true:
                    var basemodel = BaseResponseOfModel<CommonModel>()
                    
                    basemodel = BaseResponseOfModel.deserialize(from: response.value)!
                    switch basemodel.status! {
                    case true:
                        if ((basemodel.data) != nil){
//                            UserModel.shareUser.data?.description = (basemodel.data?.description)!
                            
                            self.contentLabel.text = (basemodel.data?.description)!
                            self.statusImageView.image = UIImage.init(named: "认证失败")
                        }
                        
                    case false:
                         MBProgressHUD.alertShow(in: self.view, message:basemodel.msg, hidenAfter: 0.8, mode: MBProgressHUDMode.text)
                    }
                    
                case false:
                    print(response.result.error!)
                }
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
